package com.taxi.controller;

import com.taxi.request.VerificationCodeDTO;
import com.taxi.result.Result;
import com.taxi.service.VerificationCodeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author: aniu
 * @Date: 2023/9/19
 * @ClassName: VerificationCodeController
 * @Description: Write class functionality and purpose here.
 * @Version: 1.0
 */
@RestController
public class VerificationCodeController {
    @Autowired
    private VerificationCodeService verificationCodeService;

    //获取验证码
    @ApiOperation("获取验证码")
    @PostMapping("/verification-code")
    public Result verificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        return verificationCodeService.generatorCode(passengerPhone);
    }

    //校验验证码
    @ApiOperation("校验验证码")
    @PostMapping("/verification-code-check")
    public Result checkVerificationCode(@RequestBody VerificationCodeDTO verificationCodeDTO){
        String passengerPhone = verificationCodeDTO.getPassengerPhone();
        String verificationCode = verificationCodeDTO.getVerificationCode();
        return verificationCodeService.checkCode(passengerPhone, verificationCode);
    }
}
